--TEST--
bool MySQLndUhConnection::send_query(resource $connection, string $query)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function sendQuery($res, $query) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			return parent::sendQuery($res, $query);
		}
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);
	if (true != ($tmp = $conn->query("SELECT 1 as 'one' FROM DUAL", MYSQLI_ASYNC |  MYSQLI_USE_RESULT)))
		printf("[001] Expecting true got %s\n", var_export($tmp));

	$links = array($conn);
	$errors = array($conn);
	$reject = array($conn);

	if (1 !== ($tmp = (mysqli_poll($links, $errors, $reject, 0, 10000))))
		printf("[002] Expecting int/1 got %s/%s\n", gettype($tmp), var_export($tmp, true));

	if (!is_array($links) || empty($links))
		printf("[003] Expecting non-empty array got %s/%s\n", gettype($links), var_export($links, true));
	else
		foreach ($links as $link) {
			if (is_object($res = mysqli_reap_async_query($link))) {
				// Yes, you can fetch a result - the query has been processed
				var_dump(mysqli_fetch_assoc($res));
				mysqli_free_result($res);
			} else if ($link->errno > 0) {
				printf("[003] Error: %d\n", $link->errno);
			}
		}

	mysqlnd_uh_set_connection_proxy(new proxy());
	mysqlnd_uh_test\query_test::mysqli($conn);

	if (true != ($tmp = $conn->query("SELECT 2 as 'two' FROM DUAL", MYSQLI_ASYNC |  MYSQLI_USE_RESULT)))
		printf("[001] Expecting true got %s\n", var_export($tmp));

	$links = array($conn);
	$errors = array($conn);
	$reject = array($conn);

	if (1 !== ($tmp = (mysqli_poll($links, $errors, $reject, 0, 10000))))
		printf("[002] Expecting int/1 got %s/%s\n", gettype($tmp), var_export($tmp, true));

	if (!is_array($links) || empty($links))
		printf("[003] Expecting non-empty array got %s/%s\n", gettype($links), var_export($links, true));
	else
		foreach ($links as $link) {
			if (is_object($res = mysqli_reap_async_query($link))) {
				// Yes, you can fetch a result - the query has been processed
				var_dump(mysqli_fetch_assoc($res));
				mysqli_free_result($res);
			} else if ($link->errno > 0) {
				printf("[003] Error: %d\n", $link->errno);
			}
		}


	print "done!";
?>
--EXPECTF--
array(1) {
  ["one"]=>
  string(1) "1"
}
proxy::sendQuery(array (
  0 => NULL,
  1 => 'SELECT 2 as \'two\' FROM DUAL',
))
array(1) {
  ["two"]=>
  string(1) "2"
}
done!